//
// Buttons
// --------------------------------------------------

// Base styles
// --------------------------------------------------

.btn {
  display: inline-block;
  margin-bottom: 0; // For input.btn
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  touch-action: manipulation;
  cursor: pointer;
  background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  border: 1.5px solid transparent;
  @include button-size(
    $padding-base-vertical,
    $padding-base-horizontal,
    $font-size-base,
    $line-height-base,
    $btn-border-radius-base
  );
  @include user-select(none);

  &,
  &:active,
  &.active {
    &:focus,
    &.focus {
      @include tab-focus;
    }
  }

  &:hover,
  &:focus,
  &.focus {
    color: var(--font-color);
    outline: 0;
    text-decoration: none;
  }

  &:active,
  &.active {
    background-image: none;
    outline: 0;
    @include box-shadow(inset 0 3px 5px rgba(0, 0, 0, 0.125));
  }

  &.disabled,
  &[disabled],
  &.btn-disabled,
  fieldset[disabled] & {
    cursor: $cursor-disabled;
    @include opacity(0.5);
  }

  &#{&}-transparent {
    background-color: transparent;
    // border-color: transparent;
  }

  &.btn-full {
    width: 100%;
  }

  // &:disabled,
  // &[disabled],
  // &.disabled,
  // &.btn-disabled {
  //   @include opacity(.5);
  // }

  // [converter] extracted a& to a.btn
}

a.btn {
  &.disabled,
  fieldset[disabled] & {
    pointer-events: none; // Future-proof disabling of clicks on `<a>` elements
  }
}

// Alternate buttons
// --------------------------------------------------

.btn-default {
  @include button-variant(
    --font-color,
    --font-fill-color,
    --default-color,
    --default-states-color,
    --default-states-color,
    --default-states-color
  );
  box-shadow: var(--button-box-shadow);
  &.btn-simple:not(:focus) {
    box-shadow: unset;
  }
}
.btn-primary {
  @include button-variant(
    --font-fill-color,
    --font-fill-color,
    --primary-color,
    --primary-states-color,
    $btn-danger-border,
    --primary-light-color
  );
  box-shadow: var(--button-box-shadow);
  &.btn-simple {
    box-shadow: unset;
  }
}
// Success appears as green
.btn-success {
  @include button-variant(
    --success-color,
    --font-fill-color,
    --success-color,
    --success-states-color,
    --success-color,
    --success-light-color
  );
  background-color: transparent;
  box-shadow: var(--button-box-shadow);
  &.btn-simple {
    box-shadow: unset;
    border-color: transparent;
  }
}
// Info appears as blue-green
.btn-info {
  @include button-variant(
    --font-fill-color,
    --font-fill-color,
    --info-color,
    --info-states-color,
    $btn-info-border,
    --info-light-color
  );
  box-shadow: var(--button-box-shadow);
  &.btn-simple {
    box-shadow: unset;
  }
}
// Warning appears as orange
.btn-warning {
  @include button-variant(
    --font-fill-color,
    --font-fill-color,
    --warning-color,
    --warning-states-color,
    $btn-warning-border,
    --warning-light-color
  );
  box-shadow: var(--button-box-shadow);
  &.btn-simple {
    box-shadow: unset;
  }
}
// Danger and error appear as red
.btn-danger {
  @include button-variant(
    --font-fill-color,
    --font-fill-color,
    --danger-color,
    --danger-states-color,
    $btn-danger-border,
    --danger-light-color
  );
  box-shadow: var(--button-box-shadow);
  &.btn-simple {
    box-shadow: unset;
  }
}

.btn-cta {
  @include button-variant(
    --font-fill-color,
    --font-fill-color,
    --cta-color,
    --cta-states-color,
    $btn-danger-border,
    --cta-light-color
  );
  box-shadow: var(--button-box-shadow);
  &.btn-simple {
    box-shadow: unset;
  }
}

// Link buttons
// -------------------------

// Make a button look and behave like a link
.btn-link {
  font-weight: 400;
  color: var(--link-primary-color);
  border-radius: 0;

  &,
  &:active,
  &.active,
  &[disabled],
  fieldset[disabled] & {
    background-color: transparent;
    @include box-shadow(none);
  }
  &,
  &:hover,
  &:focus,
  &:active {
    border-color: transparent;
  }
  &:hover,
  &:focus {
    color: var(--primary-highlight-color);
    text-decoration: underline;
    background-color: transparent;
  }
  &[disabled],
  fieldset[disabled] & {
    &:hover,
    &:focus {
      color: var(--link-disabled-color);
      text-decoration: none;
    }
  }
}

// Button Sizes
// --------------------------------------------------

.btn-lg {
  // line-height: ensure even-numbered height of button next to large input
  @include button-size(
    $padding-large-vertical,
    $padding-large-horizontal,
    $font-size-large,
    $line-height-large,
    $btn-border-radius-large
  );
}
.btn-sm {
  // line-height: ensure proper height of button next to small input
  @include button-size(
    $padding-small-vertical,
    $padding-small-horizontal,
    $font-size-small,
    $line-height-small,
    $btn-border-radius-small
  );
}
.btn-xs {
  @include button-size(
    $padding-xs-vertical,
    $padding-xs-horizontal,
    $font-size-small,
    $line-height-small,
    $btn-border-radius-small
  );
}

// Block button
// --------------------------------------------------

.btn-block {
  display: block;
  width: 100%;
}

// Vertically space out multiple block buttons
.btn-block + .btn-block {
  margin-top: 5px;
}

// Specificity overrides
input[type="submit"],
input[type="reset"],
input[type="button"] {
  &.btn-block {
    width: 100%;
  }
}

.btn.btn-xs {
  line-height: var(--line-height-xs);
}
.btn-info-hollow.autohilite {
  color: var(--font-color);
  background-color: var(--default-color);
  border-color: var(--default-states-color);
  box-shadow: var(--button-box-shadow);
  & + .btn.btn-danger.btn-xs {
    line-height: var(--line-height-md);
    border: 1px solid var(--danger-color);
  }
}
